//
//  deviceSelector.h
//  TI BLE SensorTag Example
//
//  Created by Ole Andreas Torvmark on 11/15/12.
//  Copyright (c) 2012 Texas Instruments. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BLEDevice.h"
#import "SensorTagApplicationViewController.h"
#import "MBProgressHUD.h"
#import "UIView+MyToast.h"
#import "CmdData.h"

#define UUID_SERVICE  @"00001910-0000-1000-8000-00805f9b34fb"
#define UUID_READ  @"0000fff4-0000-1000-8000-00805f9b34fb"
#define UUID_WRITE  @"0000fff2-0000-1000-8000-00805f9b34fb"
#define UUID_HEART_RATE_MEASUREMENT  @"00002902-0000-1000-8000-00805f9b34fb"

//接收数据错误
#define  CMD_WORD_RET_E  'E'
//接收数据成功
#define  CMD_WORD_RET_G  'G'
//未定义的命令
#define  CMD_WORD_RET_U  'U'
//更改蓝牙设备
#define  CMD_WORD_N  'N'
//更该连接密码
#define  CMD_WORD_P  'P'

#define BOND_PASSWD_DIALOG_TAG 2
#define WARN_DIALOG_TAG 3

@interface deviceSelector : UITableViewController <CBCentralManagerDelegate,CBPeripheralDelegate,
MBProgressHUDDelegate,UIAlertViewDelegate>
{
    MBProgressHUD *mProgressHub;
    NSTimer      *mProgressTimer; //used for time out.
    
    BOOL  isShowWarning;
    UIAlertView *mWarnAlertView;
    
    CBPeripheral *mCurrentConnectPeripheral;//如连接,则从连接开始的所有操作; 如断开则从从断开开始的所有操作, 仅限一个, 既当前操作.
    BOOL  isNewPasswd;
    NSString *mConnectingPasswd;  //正在连接时的 密码.
    BOOL  isReScan;
    BOOL  isJustOpen; //是否是刚打开.
    BOOL  isAutoConnMode; //是否是自动连接模式.
    
     NSTimer  *mSendSyncCmdTimer;
}
@property (strong,nonatomic) CBCentralManager *mCentralManager;
@property (strong,nonatomic) NSMutableArray *nDevices;

@property (strong,nonatomic) NSMutableArray *nLastConnDevices;  //上次连接的设备.

@property (strong,nonatomic) UIBarButtonItem *settingBtn;
@property (strong,nonatomic) UIBarButtonItem *reScanBtn;

@end

